home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!intellic.demon.co.uk
- From: Chris Trueman <truemanc@intellic.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: char* string problem
- Date: Fri, 05 Jan 96 12:47:32 GMT
- Organization: IntelliCorp
- Message-ID: <820846052snz@intellic.demon.co.uk>
- References: <4ci7gu$68r@cloner3.netcom.com>
- Reply-To: truemanc@intellic.demon.co.uk
- X-NNTP-Posting-Host: intellic.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.30
- X-Mail2News-Path: intellic.demon.co.uk
-
- In article <4ci7gu$68r@cloner3.netcom.com>
- tstevens@ix.netcom.com "Edward Stevens " writes:
-
- > I need to prepend some switch characters to some strings passed
- >to a main program which I have renamed for use as a function.
- >
- >The calling program looks like this:
- >
- >char* the_args[4];
- >char* Aprefix = " -A";
- >char* Bprefix = " -B";
- >char* CPrefix = " -C";
- >char* Dprexix = " -D";
- >
- >the_args[0] = "user_name";
- >the_args[0] = strcat(Aprefix,the_args[0]);
-
- Your problem is that the_args[0] is being set to the address of
- Aprefix which points to three (3) blocks of memory. By executing the
- strcat you are overwriting memory you have not already allocated.
-
- - Chris
-
- -============================================================================-
- IntelliCorp Applications Consultant / E-mail: truemanc@intellic.demon.co.uk
- LiveModel and PowerModel are part / CServe: 100255,701
- of IntelliCorp's MODELWORKS / Tel : +44 (0)1344 305305
- application development suite. / Fax : +44 (0)1344 305100
- -============================================================================-
-